package org.oos.dao;

import org.oos.data.Service;
import org.oos.services.OOS4Java;
import org.oos.services.log.Logger;
import org.oos.services.log.StdLogger;
import org.oos.services.util.AtomUtils;
import org.w3c.dom.Element;

public abstract class ServiceDao
{
	AtomUtils atom;
	Logger log;
	OOS4Java oos;

	public ServiceDao()
	{
		atom = new AtomUtils();
		log = new StdLogger();  
	}
	
	public ServiceDao(OOS4Java oos)
	{
		this.oos = oos;
		atom = new AtomUtils();
		log = new StdLogger();  
	}

	protected void populateCommonfields(Service service, Element entry) throws Exception
	{
		service.id = new Integer(atom.getElementValue(entry, "oos:id"));
		service.name = atom.getElementValue(entry, "title");
		service.phone = atom.getElementValue(entry, "oos:telephone");
		service.location = atom.parseLocation(entry);
		service.externalUrl = atom.getElementValue(entry, "oos:url");
		service.url = atom.getElementValue(entry, "link", "alternate");
	}
}
